module.exports = app => {
    const express = require('express');
    const router = express.Router();
    const expressWs = require('express-ws')
    expressWs(router);

    router.ws('/notify', (ws, req) => {
        console.log('success');
        ws.send("大傻逼");
        // let interval
        // interval = setInterval(() => {
        //   if (ws.readyState === ws.OPEN) {
        //     ws.send("服务端不断发送信息~~")
        //   } else {
        //     clearInterval(interval)
        //   }
        // },2000)
        
        ws.on('message', msg => {
            console.log(msg);
            ws.send("dasabi")
        })
    })

    app.use('/socket',router);
}